<template>
	<view class="maintenlist">
		<u-navbar title="维修列表" back-icon-color="#fff"
			:background="{backgroundImage: 'linear-gradient(45deg, #68dae7, #21a4b3)'}" title-color="#FFFFFF">
		</u-navbar>
		<!-- <view class="" style="background-color: #fff;">
			<u-dropdown>
				<u-dropdown-item @change="changeStatus" v-model="status" :title="droptitle" :options="statusList"></u-dropdown-item>
				<u-dropdown-item v-model="value1" title="状态" :options="statusList"></u-dropdown-item>
			</u-dropdown>
		</view> -->
		<view class="maintenlist-list">
			<view class="maintenlist-list-item" v-if="list.length > 0">
				<view v-for="(item, index) in list" :key="index" @tap.stop="maintenInfo(item.id,item.serialNumber,item.deviceName,item.applyReason)">
					<view class="maintenlist-list-item-info" v-if="item.status == status || status == 0">
						<view class="maintenlist-list-item-info-title">
							<view class="maintenlist-list-item-info-title-left">
								<view class="maintenlist-list-item-info-title-left-time">
									{{item.deviceName}}
								</view>
							</view>
							<view class="maintenlist-list-item-info-title-right">
								<text class="maintenStatus2" v-if="item.status == 1">待接修</text>
								<text class="maintenStatus3" v-if="item.status == 2">维修中</text>
								<text class="maintenStatus4" v-if="item.status == 3">暂停中</text>
								<text class="maintenStatus5" v-if="item.status == 4">完成</text>
								<!-- <text class="maintenStatus6" v-if="item.status == 6">待验收</text> -->
							</view>
						</view> 
						<view class="maintenlist-list-item-info-text">
							<view>故障原因：{{item.applyReason}}</view>
						</view>
						<view class="maintenlist-list-item-info-bottom">
							<view class="footerTime">电话：{{item.applyPhone?item.applyPhone:""}}</view>
							<view class="hospitalName">申请人：{{item.applyPeople}}</view>
						</view>
					</view>
				</view>
				<!-- <view class="no-more-data" v-if="isReach">
					已经全部加载完了
				</view> -->
			</view>
			<view class="list-nodata" v-else>
				<image src="@/static/images/nodata.png"></image>
				<view class="list-nodata-text">暂无数据</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				role:uni.getStorageSync("role"),
				list:[],
				status:0,
				droptitle:"全部",
				isNodata:false
			}
		},
		onLoad() {
			this.getData()
		},
		onPullDownRefresh() {
			this.list = []
			this.getData()
		},
		methods:{
			getData(){
				if(this.role == "admin"){
					this.$xt.api.deviceCheckList().then(res=>{
						this.list = this.list.concat(res.rows)
						if(this.list.length == 0) this.isNodata = true
					})
				}else{
					this.$xt.api.deviceAssignList().then(res=>{
						this.list = this.list.concat(res.rows)
						if(this.list.length == 0) this.isNodata = true
					})
				}
			},
			maintenInfo(id,serialNumber,deviceName,applyReason){
				this.$u.route({
					url:'pages/device/maintenInfo',
					type:"navigateTo",
					params:{
						deviceSn:id,
						serialNumber:serialNumber,
						deviceName:deviceName,
						applyReason:applyReason
					}
				})
			},
			changeStatus(val,label){
				this.droptitle = label
			},
			reloadList(){
				this.list = []
				this.getData()
			},
		}
	}
</script>

<style scoped lang="scss">
	.maintenlist{
		&-list-item{
			width: 750rpx;
			background-color: #F5F7FB;
			padding-top: 1rpx;
			padding-bottom: 10rpx;
			&-info{
				background-color: #fff;
				margin: 20rpx 0 0  0;
				padding: 10rpx 24rpx;
				&-title{
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding-bottom: 10rpx;
					&-left{
						display: flex;
						align-items: center;
						&-time{
							font-size: 32rpx;
							// height: 24rpx;
						}
					}
				}
				&-text{
					height: 180rpx;
					background: #F5F7FB;
					border-radius: 10rpx 10rpx 10rpx 10rpx;
					padding: 5rpx 5rpx;
					font-size: 28rpx;
				}
				&-bottom{
					display: flex;
					justify-content: space-between;
					margin-top: 10rpx;
					font-size: 24rpx;
					.hospitalName{
						color:#49B9AD
					}
				}
			}
		}
		
	}
	.item-con{
		overflow: auto;
	}
	.no-more-data{
		text-align: center;
		padding-top: 5rpx;
		padding-bottom: 10rpx;
		font-size: 20rpx;
		color:#ccc
	}
	.list-nodata{
		width: 750rpx;
		height: 50vh;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		image{
			width: 250rpx;
			height: 250rpx;
		}
		&-text{
			margin-top: 10rpx;
			color:#666
		}
	}
	.maintenStatus1{
		color:#5555ff
	}
	.maintenStatus2{
		color:#ff007f
	}
	.maintenStatus3{
		color:#00aaff
	}
	.maintenStatus4{
		color:#aa007f
	}
	.maintenStatus5{
		color:#00aa00
	}
	.maintenStatus6{
		color:#00aa00
	}
</style>